//
//  NSString+LY.m
//  SelectCity
//
//  Created by liuyan on 2019/3/13.
//  Copyright © 2019年 liuyan. All rights reserved.
//

#import "NSString+LY.h"

@implementation NSString (LY)

- (CGSize)sizeOfFont:(UIFont *)font maxSize:(CGSize)maxSize{
    NSDictionary *attribute = @{NSFontAttributeName : font};
    return [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attribute context:nil].size;
}

//校验6-20位数字和字母组合
-(BOOL)checkPassword{
    NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z0-9]{6,20}";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",pattern];
    BOOL isMatch = [pred evaluateWithObject:self];
    return isMatch;
}


@end
